package com.df.excel_export.validator.vadator_impl.type_string;

import com.df.excel_export.common.ExcelTable;
import com.df.excel_export.common.ExportTask;
import com.df.excel_export.validator.AbstractIFieldValidator;
import com.df.excel_export.validator.IFieldValidator;
import com.df.excel_export.validator.IValidatorFactory;

import java.util.List;

public class StringResourceValidator extends AbstractIFieldValidator implements IValidatorFactory {
    public String resourceName;//资源名，会根据此资源名查找配置的资源路径
    @Override
    public boolean support(String filedType, String ruleStr) {
        if(!filedType.equals("string")){
            return false;
        }
        if(ruleStr.startsWith("resource(") && ruleStr.endsWith(")")){
            return true;
        }
        return false;
    }

    @Override
    public IFieldValidator create(String filedType, String ruleStr) {
        StringResourceValidator validator = new StringResourceValidator();
        String resourceName = ruleStr.substring(9, ruleStr.length() - 1);
        validator.resourceName = resourceName;
        return validator;
    }

    @Override
    public Integer getPriority() {
        return 0;
    }

    @Override
    public boolean validate(ExcelTable checkTable, List<Object> rowData, Integer dataRowIndex, Integer fieldIndex, String fieldName, String fieldTypeStr, Object filedValue) {

        //TODO 根据resourceName去配置文件中查找资源名对应的路径
        //TODO 组装单元格的路径
        //TODO 检查本地文件中是否有此文件
        // 资源路径要相对于资源根路径
        return false;
    }
}
